package com.kkyy.findmusic.controller;

import com.kkyy.common.utils.R;
import com.kkyy.findmusic.entity.MvsEntity;
import com.kkyy.findmusic.service.MvsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping("/findmusic")
public class MvsController {
    @Autowired
    private MvsService mvsService;

    // 查询mv(前端)
    @RequestMapping("/mvs")
    public R getMvs() {
        List<MvsEntity> mvs = mvsService.getMvs2();
        return R.ok().put("data", mvs);
    }

    // 远程调用查询mv(后台)
    @RequestMapping("/mvs2")
    public List<MvsEntity> getMvs2() {
        List<MvsEntity> mvs = mvsService.getMvs();
        return mvs;
    }

    // 远程调用删除mv
    @RequestMapping("/mvdel")
    public void delMvById(@RequestParam("id") Integer id) {
        mvsService.delMvById(id);
    }

    // 远程调用上架mv
    @RequestMapping("/upMv")
    public void upMvById(@RequestParam("id") Integer id) {
        mvsService.upMvById(id);
    }

    // 远程调用下架mv
    @RequestMapping("/downMv")
    public void downMvById(@RequestParam("id") Integer id) {
        mvsService.downMvById(id);
    }

    @RequestMapping(value = "/addMvInfo", method = RequestMethod.GET)
    void addMvInfo(
            @RequestParam("picurl") String picurl,
            @RequestParam("count") Integer count,
            @RequestParam("mvreco") String mvreco,
            @RequestParam("mvart") String mvart,
            @RequestParam("mvname") String mvname,
            @RequestParam("location") Integer location) {
        mvsService.addMvInfo(picurl, count, mvreco, mvart, mvname, location);
    }
}